package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.CargoManager;
import service.factory.ManagerFactory;

/**
 * Servlet implementation class DeleteCargoServlet
 */
@WebServlet("/cargo/delete")
public class DeleteCargoServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private CargoManager cargoManager;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DeleteCargoServlet() {
        super();
        cargoManager = ManagerFactory.getCargoManagerInstance();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String c_id = request.getParameter("id");
		String w_id = request.getParameter("w_id");
		cargoManager.delete(c_id);
		request.getRequestDispatcher("cargo?id="+w_id).forward(request, response);;
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
